{extend name="admin/b2c/base" /}
{block name="resources"/}
<link rel="stylesheet" type="text/css" href="ADMIN_CSS/product.css">
<style type="text/css">
.fun-a {
	margin-top: 0px;
	padding: 6px 15px 0 15px;
}
.style0list tbody td a{
	margin-left: 8px;
}
.num{width:40px;text-align:center;}	
.cell_total{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;width:250px;display: block;}
.style0list table input {
	margin-bottom: 0px;
}

.style0list table input.sort {
	width: auto;
	text-align: center;
}

.style0list tbody td {
	line-height: 28px;
}
</style>
{/block}
{block name="right_tab"}
<li><a class="nscs-table-handle_green" href="ADMIN_MAIN/Config/adddocument.html" ><i class="fa fa-plus-circle"></i>&nbsp;添加帮助内容</a></li>
{/block}
{block name="main"}
<div class="mod-table">
	<div class="con style0list">
		<table>
			<colgroup>
				<col style="width: 1%">
				<col style="width: 8%;">
				<col style="width: 15%;">
				<col style="width: 20%;">
				<col style="width: 10%;">
				<col style="width: 20%;">
				<col style="width:auto">
			</colgroup>
			<thead>
				<tr align="center">
					<th><label><input value="" name="" id="ckall" type="checkbox" onClick="CheckAll()"></label></th>
					<th class="x-tab"><div class="iconbg-arrow up">排序</div></th>
					<th class="x-tab"><div class="iconbg-arrow up">标题</div></th>
					<th class="x-tab"><div class="iconbg-arrow up">分类</div></th>
					<th class="x-tab">操作</th>
				</tr>
			</thead>
			<tbody id="linkList"></tbody>
		</table>
	</div>
</div>
{/block}
{block name="script"}
{include file="admin/b2c/pageCommon" /}
{include file="admin/b2c/openDialog" /}
<script type="text/javascript">
//全选
function CheckAll(){
	if($("#linkList input[type = 'checkbox']").attr("checked")){
		$("#linkList input[type = 'checkbox']").attr("checked",false);
	}else{
		$("#linkList input[type = 'checkbox']").attr("checked",true);
	}
}

//分页数据
function LoadingInfo(pageIndex) {
	var search_text = $("#search_text").val();
	$.ajax({
		type : "post",
		url : "ADMIN_MAIN/Config/helpDocument",
		data : {
			"pageIndex" : pageIndex
		},
		success : function(data) {
			$("#page_count").val(data["page_count"]);
			$("#pageNumber a").remove();
			var html = '';
			if (data["data"].length > 0) {
				for (var i = 0; i < data["data"].length; i++) {
					html += '<tr align="center">';
					html += '<td><div class="cell"><label><input name="sub" type="checkbox" value="'+ data['data'][i]['id']+'"></label></div></td>';
					html += '<td><input type="text" min="0" value="'+ data["data"][i]["sort"]+'" class="num" onchange="updateDocument('+data["data"][i]["id"]+','+i+','+data["data"][i]["id"]+')" id="sort'+i+'"></td>';
					html += '<td><input type="text" id="title'+i+'" value="' + data["data"][i]["title"]+ '"onchange="updateDocument('+data["data"][i]["id"]+','+i+','+data["data"][i]["id"]+')" /></td>';
					html += '<td>'+data["data"][i]["class_name"]+'</td>';
					//<a href="javascript:help_delete('+data['data'][i]['id']+')">删除</a>&nbsp;&nbsp;
					html += '<td class="center"><a href="ADMIN_MAIN/config/updatedocument?id='+data['data'][i]['id']+'" >修改</a>&nbsp;&nbsp;<a href="SHOP_MAIN/helpcenter/index?id='+ data['data'][i]['id']+'&class_id='+data["data"][i]["class_id"]+'" target="_blank">预览</a></td>';
					html += '</tr>';
				}
			} else {
				html += '<tr align="center"><th colspan="9">暂无帮助类型</th></tr>';
			}
			$(".style0list tbody").html(html);
			var totalpage = $("#page_count").val();
			if (totalpage == 1) {
				changeClass("all");
			}
			var $html = pagenumShow(jumpNumber,totalpage,{$pageshow})
			$("#pageNumber").append($html);
		}
	});
}

/*
*修改input值
*/
function updateDocument(id,index,class_id){
	var title = $("#title"+index).val();
	var sort = $("#sort"+index).val();
	$.ajax({
		type:"post",
		url:"ADMIN_MAIN/Config/updateDocument",
		data:{ 'id' : id, 'title':title,'sort':sort,"class_id":class_id},
		async:true,
		success: function (data) {
			if(data <= 0){
				showMessage('error', data['message']);
			}else{
				showMessage('success', data['message']);
			}
		}
	});
}

/*
*删除标题
*/
// function help_delete(id){
// 	$( "#dialog" ).dialog({
//         buttons: {
//             "确定,#e57373": function() {
//                 $(this).dialog('close');
//                 $.ajax({
//         			type : "post",
//         			url: "ADMIN_MAIN/Config/titleDelete",
//         			async : true,
//         			data: { "id": id },
//         			success : function(data) {
//         				if(data["code"] > 0 ){
//         					showMessage('success', data["message"],'PLATFORM_MAIN/config/helpdocument');
//         				}else{
//         					showMessage('error', data["message"]);
//         				}
//         			}
//         		});
//             },
//             "取消": function() {
//                 $(this).dialog('close');
//             }
//         },
//         contentText:"你确定删除该内容吗？",
//         title:"消息提醒"
//     });
// }
</script>
{/block}